package com.trkj.service.cf;

import java.util.ArrayList;
import java.util.List;

import javax.print.attribute.standard.PageRanges;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.trkj.dao.cf.ZszlTypeDAO;
import com.trkj.pojo.Certificate;
import com.trkj.pojo.CertificateType;
import com.trkj.pojo.ZszlType;
import com.trkj.service.ServiceException;
import com.trkj.vo.cf.CertificateTypeVo;
import com.trkj.vo.cf.CertificateVo;
import com.trkj.vo.cf.CourseVo;

@Service
@Transactional(rollbackFor=ServiceException.class)
public class ZszlTypeService {
	@Autowired
	private ZszlTypeDAO zszlTypeDAO;
	public List<CertificateVo> findAll(int page, int rows,String zszlName) {
		List<Object[]> list = zszlTypeDAO.findAll(new PageRequest(page-1,rows),"%"+zszlName+"%");
		List<CertificateVo> list1 = new ArrayList<>();
		if(list != null){
			for(Object[] objs: list){
				Certificate ct = (Certificate) objs[0];
				ZszlType zt = (ZszlType) objs[1];
				CertificateVo vo = new CertificateVo();
				 vo.setZszlId(zt.getZszlId());
				 vo.setZszlType(zt);
				 vo.setCertiId(ct.getCertiId());
				 vo.setCertiName(ct.getCertiName());
				 vo.setCertiOwnertype(ct.getCertiOwnertype());
				 vo.setCertiUsestate(ct.getCertiUsestate());
				 vo.setCertiEffectivedate(ct.getCertiEffectivedate());
				 vo.setCertiBorrowstate(ct.getCertiBorrowstate());
				 list1.add(vo);
			}
		}
		return list1;
	}
	public long pageCount() {
		 
		return zszlTypeDAO.count();
	}
	public List<ZszlType> findAll1() {
		return  zszlTypeDAO.findAll12();
	}
		
}
